package me.panpf.sketch.sample.vt;

import me.panpf.sketch.sample.vt.utils.FileUtil;
import me.panpf.sketch.sample.vt.utils.PixelUtil;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 *  ExampleOhosTest
 *
 * @author hw
 * @since 2021/7/15
 */
public class ExampleOhosTest {
    Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    /**
     * testBundleName
     */
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("me.panpf.sketch.sample.vt", actualBundleName);
    }

    /**
     * PixelUtil_fp2px
     */
    @Test
    public void PixelUtil_fp2px() {
        PixelUtil.initContext(context);
        float pxTurn = PixelUtil.fp2px(15);
        Assert.assertEquals(45.0, pxTurn, 0.0);
    }

    /**
     * PixelUtil_vp2px
     */
    @Test
    public void PixelUtil_vp2px() {
        PixelUtil.initContext(context);
        float pxTurn = PixelUtil.vp2px(15);
        Assert.assertEquals(45.5, pxTurn, 0.0);
    }

    /**
     * PixelUtil_screenWidth
     */
    @Test
    public void PixelUtil_screenWidth() {
        PixelUtil.initContext(context);
        int width = PixelUtil.screenWidth();
        Assert.assertTrue(width > 0);
    }

    /**
     * PixelUtil_screenHeight
     */
    @Test
    public void PixelUtil_screenHeight() {
        PixelUtil.initContext(context);
        int height = PixelUtil.screenHeight();
        Assert.assertTrue(height > 0);
    }

    /**
     * FileUtil_formatFileSizeKB
     */
    @Test
    public void FileUtil_formatFileSizeKB() {
        String size = FileUtil.formatFileSize(200000);
        Assert.assertEquals("200.00KB", size);
    }

    /**
     * FileUtil_formatFileSizeMB
     */
    @Test
    public void FileUtil_formatFileSizeMB() {
        String size = FileUtil.formatFileSize(200000000);
        Assert.assertEquals("200.00MB", size);
    }

    /**
     * FileUtil_formatFileSizeGB
     */
    @Test
    public void FileUtil_formatFileSizeGB() {
        String size = FileUtil.formatFileSize(2000000000);
        Assert.assertEquals("2.00GB", size);
    }
}